package week04;

	import java.util.Arrays;
	import java.util.Scanner;

	class PersonOverride {
		private String name;
		private boolean gender;
		private int age;

		public PersonOverride() {
			this("default", 1, true);
		}

		public PersonOverride(String name, int age, boolean gender) {
			this.name = name;
			this.age = age;
			this.gender = gender;
		}

		@Override
		public String toString() {
			return name + "-" + age + "-" + gender;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			PersonOverride other = (PersonOverride) obj;
			if (age != other.age)
				return false;
			if (gender != other.gender)
				return false;
			if (name == null) {
				if (other.name != null)
					return false;
			} else if (!name.equals(other.name))
				return false;
			return true;
		}

	}

	public class week0402 {
		public static void main(String[] args) {
			Scanner in = new Scanner(System.in);
			int n1 = in.nextInt();
			PersonOverride[] persons1 = new PersonOverride[n1];
			for (int i = 0; i < n1; i++) {
				persons1[i] = new PersonOverride();
			}
			int n2 = in.nextInt();
			int count = 0;
			PersonOverride[] persons2 = new PersonOverride[n2];
			for (int i = 0; i < n2; i++) {
				String name;
				int age;
				boolean gender;
				name = in.next();
				age = in.nextInt();
				gender = in.nextBoolean();
				PersonOverride temp = new PersonOverride(name, age, gender);
				boolean flag = true;
				for (int j = 0; j < count; j++) {
					if (persons2[j].equals(temp)) {
						flag = false;
						break;
					}
				}
				if (flag) {
					persons2[count++] = new PersonOverride(name, age, gender);
				}
			}
			for (PersonOverride p : persons1) {
				System.out.println(p);
			}
			for (PersonOverride p : persons2) {
				if (p == null)
					break;
				System.out.println(p);
			}
			System.out.println(count);
			System.out.println(Arrays.toString(PersonOverride.class.getConstructors()));
		}

	}

